/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kai.zhouzhi.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "product_cate", catalog = "nature", schema = "")
@NamedQueries({
    @NamedQuery(name = "ProductCate.findAll", query = "SELECT p FROM ProductCate p"),
    @NamedQuery(name = "ProductCate.findByProductCateId", query = "SELECT p FROM ProductCate p WHERE p.productCateId = :productCateId"),
    @NamedQuery(name = "ProductCate.findByProductCateName", query = "SELECT p FROM ProductCate p WHERE p.productCateName = :productCateName"),
    @NamedQuery(name = "ProductCate.findByProductCateDesc", query = "SELECT p FROM ProductCate p WHERE p.productCateDesc = :productCateDesc")})
public class ProductCate implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "product_cate_id", nullable = false)
    private Integer productCateId;
    @Basic(optional = false)
    @Column(name = "product_cate_name", nullable = false, length = 50)
    private String productCateName;
    @Column(name = "product_cate_desc", length = 1000)
    private String productCateDesc;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "productCateId", fetch = FetchType.EAGER)
    private List<Product> productList;

    public ProductCate() {
    }

    public ProductCate(Integer productCateId) {
        this.productCateId = productCateId;
    }

    public ProductCate(Integer productCateId, String productCateName) {
        this.productCateId = productCateId;
        this.productCateName = productCateName;
    }

    public Integer getProductCateId() {
        return productCateId;
    }

    public void setProductCateId(Integer productCateId) {
        this.productCateId = productCateId;
    }

    public String getProductCateName() {
        return productCateName;
    }

    public void setProductCateName(String productCateName) {
        this.productCateName = productCateName;
    }

    public String getProductCateDesc() {
        return productCateDesc;
    }

    public void setProductCateDesc(String productCateDesc) {
        this.productCateDesc = productCateDesc;
    }

    public List<Product> getProductList() {
        return productList;
    }

    public void setProductList(List<Product> productList) {
        this.productList = productList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productCateId != null ? productCateId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProductCate)) {
            return false;
        }
        ProductCate other = (ProductCate) object;
        if ((this.productCateId == null && other.productCateId != null) || (this.productCateId != null && !this.productCateId.equals(other.productCateId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.kai.zhouzhi.entity.ProductCate[productCateId=" + productCateId + "]";
    }

}
